package com.buaa.controller;

import com.buaa.common.Result;
import com.buaa.dto.AccidentSceneMapDTO;
import com.buaa.service.impl.AccidentSceneMapServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/scene")
public class AccidentSceneController {


    @Autowired
    private AccidentSceneMapServiceImpl mapService;

    // 删除
    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable("id") Integer id, HttpServletRequest request){
       return mapService.deleteBySceneId(id, request);
    }

    // 更新
    @PutMapping
    public Result update(@RequestBody AccidentSceneMapDTO dto, HttpServletRequest request){
        return mapService.updateMap(dto, request);
    }

    // 保存
    @PostMapping("/save")
    public Result save(@RequestBody AccidentSceneMapDTO dto, HttpServletRequest request){
        return mapService.saveMap(dto, request);
    }

    // 翻页
    @GetMapping("/page")
    public Map<String,Object> findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize){

        return mapService.findPage(pageNum, pageSize);
    }
}
